WPS Office.apk(点击下载) / SharePlayIndexBaseView.java


package cn.wps.moffice.common.shareplay2;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import cn.wps.moffice.common.beans.RippleAlphaLinearLayout;
import cn.wps.moffice.common.scanqrcode.BaseWebViewActivity;
import cn.wps.moffice.main.common.viewcontrols.ViewTitleBar;
import cn.wps.moffice.main.push.explore.PushTipsWebActivity;
import cn.wps.moffice_eng.R;
import com.iflytek.speech.VoiceWakeuperAidl;
import java.util.EnumSet;

public class SharePlayIndexBaseView extends fyq {
    private static final String APPLY_AGORA_URL = "https://ios.wps.cn/operationPromotion/wpsMeetingFreeActivation/index.html?enterType=tool";
    private static final String URL_KNOW_MORE_ABOUT_SHAREPLAY = "http://mo.wps.cn/scattered_activities/gxbf.html";
    private TextView mApplyAgoraDescView;
    private View mApplyAgoraLayout;
    private String mApplyClickStats;
    private ecu mController;
    private TextView mFreeApplyAgora;
    private RippleAlphaLinearLayout mFreeApplyAgoraLay;
    private Dialog mMobileNetworkDlg;
    private Dialog mNetworkOfflineDlg;
    private SharePlayIndexView sharePlayIndexView;

    public interface IUpdateAgoraListener {
        void hasAgora(tgk tgk);

        void noHasAgora(tgk tgk);
    }

    public SharePlayIndexBaseView(Activity activity) {
        super(activity);
        this.sharePlayIndexView = new SharePlayIndexView(activity);
        setListener(this.sharePlayIndexView);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void applyAgoraWebView() {
        if (this.mController == null) {
            this.mController = new ecu(this.mActivity);
        }
        this.mController.updateWpsSid();
        Intent intent = new Intent(this.mActivity, PushTipsWebActivity.class);
        intent.putExtra(hbe.frL, APPLY_AGORA_URL);
        this.mActivity.startActivityForResult(intent, VoiceWakeuperAidl.RES_FROM_CLIENT);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void checkAgoraApply() {
        updateApplyAgora(new IUpdateAgoraListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass11 */

            @Override // cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.IUpdateAgoraListener
            public void hasAgora(tgk tgk) {
                SharePlayIndexBaseView.this.updateApplyAgoraTime(tgk);
            }

            @Override // cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.IUpdateAgoraListener
            public void noHasAgora(tgk tgk) {
                SharePlayIndexBaseView.this.applyAgoraWebView();
            }
        });
    }

    private boolean isOpenApplyArgo() {
        return edf.aUF() || edf.aUE();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void openUrl(String str) {
        Intent intent = new Intent(this.mActivity, BaseWebViewActivity.class);
        intent.putExtra("url", str);
        intent.putExtra("public_share_play_know_more", true);
        this.mActivity.startActivityForResult(intent, 1);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void selectFile() {
        Intent a = fvf.a(this.mActivity, (EnumSet<cqd>) EnumSet.of(cqd.PPT), false);
        if (a != null) {
            Bundle bundle = new Bundle();
            bundle.putInt("KEY_HOME_SELECT_MODE", 2);
            bundle.putString("key_request", "request_open");
            a.putExtras(bundle);
            this.mActivity.startActivityForResult(a, 257);
            dwp.lV("public_shareplay_selectfile");
        }
    }

    private void setListener(SharePlayIndexView sharePlayIndexView2) {
        sharePlayIndexView2.setOnClickKnowMore(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass4 */

            public void onClick(View view) {
                SharePlayIndexBaseView.this.openUrl(SharePlayIndexBaseView.URL_KNOW_MORE_ABOUT_SHAREPLAY);
            }
        });
        sharePlayIndexView2.setOnClickReturn(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass5 */

            public void onClick(View view) {
                SharePlayIndexBaseView.this.mActivity.finish();
            }
        });
        sharePlayIndexView2.setOnClickClose(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass6 */

            public void onClick(View view) {
                SharePlayIndexBaseView.this.mActivity.finish();
            }
        });
        sharePlayIndexView2.setOnClickLaunch(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass7 */

            public void onClick(View view) {
                dwp.lV("public_shareplay_invite");
                if (lwd.isWifiConnected(SharePlayIndexBaseView.this.mActivity)) {
                    edf.ic(true);
                    SharePlayIndexBaseView.this.selectFile();
                } else if (lwd.hv(SharePlayIndexBaseView.this.mActivity)) {
                    SharePlayIndexBaseView.this.mMobileNetworkDlg = edf.c(SharePlayIndexBaseView.this.mActivity, new DialogInterface.OnClickListener() {
                        /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass7.AnonymousClass1 */

                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (i == -1) {
                                edf.ic(true);
                                SharePlayIndexBaseView.this.selectFile();
                            }
                        }
                    }, true);
                    SharePlayIndexBaseView.this.mMobileNetworkDlg.show();
                } else {
                    SharePlayIndexBaseView.this.showNetworkOfflineDialog();
                }
            }
        });
        sharePlayIndexView2.setOnClickJoin(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass8 */

            public void onClick(View view) {
                if (luf.isInMultiWindow(SharePlayIndexBaseView.this.mActivity)) {
                    lvg.a(SharePlayIndexBaseView.this.mActivity, SharePlayIndexBaseView.this.mActivity.getResources().getString(R.string.public_not_support_in_multiwindow), 0);
                    return;
                }
                edf.ic(true);
                ((SharePlayIndexActivity) SharePlayIndexBaseView.this.mActivity).getJoinDialog(SharePlayIndexBaseView.this.mActivity).show();
                dwp.lV("public_shareplay_access");
            }
        });
        sharePlayIndexView2.setOnClickApplyAgora(new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass9 */

            public void onClick(View view) {
                if (!TextUtils.isEmpty(SharePlayIndexBaseView.this.mApplyClickStats)) {
                    dwp.lV(SharePlayIndexBaseView.this.mApplyClickStats);
                }
                if (!ebo.arU()) {
                    fpp.rX("1");
                    ebo.c(SharePlayIndexBaseView.this.mActivity, new Runnable() {
                        /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass9.AnonymousClass1 */

                        public void run() {
                            if (ebo.arU()) {
                                SharePlayIndexBaseView.this.checkAgoraApply();
                            }
                        }
                    });
                    return;
                }
                SharePlayIndexBaseView.this.applyAgoraWebView();
            }
        });
    }

    private void updateApplyAgora(final IUpdateAgoraListener iUpdateAgoraListener) {
        fcx.p(new Runnable() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass12 */

            public void run() {
                if (SharePlayIndexBaseView.this.mController == null) {
                    SharePlayIndexBaseView.this.mController = new ecu(SharePlayIndexBaseView.this.mActivity);
                }
                SharePlayIndexBaseView.this.mController.updateWpsSid();
                final tgk agoraApplyInfo = SharePlayIndexBaseView.this.mController.getAgoraApplyInfo();
                fcz.b(new Runnable() {
                    /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass12.AnonymousClass1 */

                    public void run() {
                        if (agoraApplyInfo == null || TextUtils.isEmpty(agoraApplyInfo.result) || !"ok".equals(agoraApplyInfo.result)) {
                            if (iUpdateAgoraListener != null) {
                                iUpdateAgoraListener.noHasAgora(agoraApplyInfo);
                            }
                        } else if (iUpdateAgoraListener != null) {
                            iUpdateAgoraListener.hasAgora(agoraApplyInfo);
                        }
                    }
                }, false);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void updateApplyAgoraTime(tgk tgk) {
        String string;
        boolean z;
        String string2;
        boolean z2 = true;
        if (tgk == null || TextUtils.isEmpty(tgk.result) || !"ok".equals(tgk.result)) {
            string = this.mActivity.getResources().getString(R.string.ppt_shareplay_free_use);
            z2 = false;
            z = false;
            string2 = this.mActivity.getResources().getString(R.string.ppt_shareplay_support_speech);
        } else {
            long j = tgk.uFc;
            long j2 = tgk.gbs;
            z = (j2 - j) / 86400 > 3;
            String agoraApplyTime = this.mController.getAgoraApplyTime(j, j2);
            string = this.mActivity.getResources().getString(R.string.ppt_shareplay_continue_apply);
            string2 = String.format(this.mActivity.getResources().getString(R.string.ppt_shareplay_apply_prompt), agoraApplyTime);
        }
        updateApplyAgoraView(string2, z, string, z2);
    }

    public void dismissMobileNetworkTipDialog() {
        if (this.mMobileNetworkDlg != null) {
            this.mMobileNetworkDlg.dismiss();
        }
    }

    public void dismissNetworkOfflineDialog() {
        if (this.mNetworkOfflineDlg != null) {
            this.mNetworkOfflineDlg.dismiss();
        }
    }

    @Override // defpackage.fys, defpackage.fyq
    public View getMainView() {
        this.mApplyAgoraDescView = (TextView) this.sharePlayIndexView.findViewById(R.id.agora_apply_desc);
        this.mFreeApplyAgora = (TextView) this.sharePlayIndexView.findViewById(R.id.free_apply_agora);
        this.mFreeApplyAgoraLay = (RippleAlphaLinearLayout) this.sharePlayIndexView.findViewById(R.id.free_apply_agora_lay);
        this.mApplyAgoraLayout = this.sharePlayIndexView.findViewById(R.id.apply_agora_layout);
        View findViewById = this.sharePlayIndexView.findViewById(R.id.btn_back);
        if (findViewById != null) {
            findViewById.setOnClickListener(new View.OnClickListener() {
                /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass1 */

                public void onClick(View view) {
                    SharePlayIndexBaseView.this.mActivity.finish();
                }
            });
        }
        AnonymousClass2 r1 = new View.OnClickListener() {
            /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass2 */

            public void onClick(View view) {
                Intent intent = new Intent(SharePlayIndexBaseView.this.mActivity, PushTipsWebActivity.class);
                intent.setAction("android.intent.action.MAIN");
                intent.addCategory("android.intent.category.DEFAULT");
                intent.putExtra(hbe.frL, "https://d.wps.cn/v/8sUFg?mode=pure");
                SharePlayIndexBaseView.this.mActivity.startActivity(intent);
            }
        };
        ViewTitleBar viewTitleBar = (ViewTitleBar) this.sharePlayIndexView.findViewById(R.id.title_bar);
        if (viewTitleBar != null) {
            lvw.cm(viewTitleBar.gBE);
            viewTitleBar.gBO.setOnClickListener(new View.OnClickListener() {
                /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass3 */

                public void onClick(View view) {
                    SharePlayIndexBaseView.this.mActivity.finish();
                }
            });
            viewTitleBar.setNeedSecondText(true, this.mActivity.getString(R.string.documentmanager_history_record_feedback), luf.dip2px(this.mActivity, 14.0f), r1);
        }
        this.sharePlayIndexView.setOnClickFeedback(r1);
        return this.sharePlayIndexView;
    }

    @Override // defpackage.fyq
    public int getViewTitleResId() {
        return R.string.ppt_sharedplay;
    }

    public void showNetworkOfflineDialog() {
        this.mNetworkOfflineDlg = edf.a((Context) this.mActivity, (DialogInterface.OnCancelListener) null, true);
        this.mNetworkOfflineDlg.show();
    }

    public void updateApplyAgoraInfo() {
        if (isOpenApplyArgo()) {
            updateApplyAgora(new IUpdateAgoraListener() {
                /* class cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.AnonymousClass10 */

                @Override // cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.IUpdateAgoraListener
                public void hasAgora(tgk tgk) {
                    SharePlayIndexBaseView.this.updateApplyAgoraTime(tgk);
                }

                @Override // cn.wps.moffice.common.shareplay2.SharePlayIndexBaseView.IUpdateAgoraListener
                public void noHasAgora(tgk tgk) {
                    SharePlayIndexBaseView.this.updateApplyAgoraTime(tgk);
                }
            });
        }
    }

    public void updateApplyAgoraView(String str, boolean z, String str2, boolean z2) {
        if (z) {
            this.mFreeApplyAgoraLay.setVisibility(8);
        } else {
            this.mFreeApplyAgora.setVisibility(0);
            this.mFreeApplyAgora.setText(str2);
        }
        this.mApplyAgoraDescView.setText(str);
        if ((!z2 || !edf.aUF()) && (z2 || !edf.aUE())) {
            this.mApplyAgoraLayout.setVisibility(8);
            return;
        }
        if (!z2 || z) {
            dwp.lV("public_apps_shareplay_freeuesbutton_show");
            this.mApplyClickStats = "public_apps_shareplay_freeuesbutton_click";
        } else {
            dwp.lV("public_apps_shareplay_continuefreeuesbutton_show");
            this.mApplyClickStats = "public_apps_shareplay_continuefreeuesbutton_click";
        }
        this.mApplyAgoraLayout.setVisibility(0);
    }
}